Q: I've created a palette object with subviews. These subviews are created within the
\b init:
\b0 method for my object. I store the
\b id's
\b0 for these subviews in instance variables in the object. When I instantiate one of these objects by dragging it from the palette, the subviews are there—they are visible—yet none of my code for resizing or accessing these subviews is working. Why?\
\
Q: When I instantiate and initialize one of my palette objects, the instance variables do not contain the values to which they were initialized. What's going on?\
\
A: If you debug the object that you have written within the context of Interface Builder (try using
\b fprintf(stderr, ...)
\b0 statements, if nothing else), you will discover that all of the instance variables and outlets are nil, even though at one point all of the instance variables were initialized and the objects to which the outlets once pointed still exist. This is because the object is being archived and unarchived. It is your responsibility to provide the specific archiving and unarchiving code for each of your objects. This is accomplished within the
\b read:
\b0 and
\b write:
\b0 methods for your object. Within those methods, you must read and write
\i all
\i0 of the instance variables for your object—even the
\b id's
\b0 . If you do not do this, then instance variables will contain bogus values, and outlets will become disconnected even though the objects themselves exist. (View archiving automatically handles archiving and unarchiving subviews.)\
\
Here is a code snippet which illustrates what you must do. The object in question contains six instance variables: 1 string, 2 booleans, and 3 id's which point to subviews of the object.\